/*
 * RevenueSourceFactory.java
 *
 * Created on March 21, 2007, 5:43 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */


package finalintex2web;
import java.util.*;
import java.io.*;
import java.sql.*;

/**
 * database access object for ravenue sources
 */
public class RevenueSourceFactory {
    
    Map<String,RevenueSourceDAO> m = new TreeMap<String,RevenueSourceDAO>();
   
    
    
    ///////////////////////////////////////
    ///   Singleton pattern
     private static RevenueSourceFactory instance = null;
   
    
    /** Creates a new instance of RevenueSourceDAO */
    private RevenueSourceFactory() {
         m.put("backup",BackupDAO.getInstance());
         m.put("repair",RepairDAO.getInstance());
         m.put("rental",RentalDAO.getInstance());
         m.put("fee",RentalDAO.getInstance());
    }
   
    /**
     * 
     * @return 
     */
    public static synchronized RevenueSourceFactory getInstance() {
        if (instance == null) {
            instance = new RevenueSourceFactory();
        }
     
        return instance;
    }
    
    /**
     * 
     * @param type 
     * @return 
     */
    public RevenueSourceDAO GetDAO(String type){
       RevenueSourceDAO revsrc = m.get(type);
       
       return revsrc;
    }
}